<div class="wrapper clearfix">
	
	<?php $this->load->view('ucenter/sidebar');?>
	
	<div class="content">
		
		<h3>我的订单</h3>
		
		<ul class="clearfix">
			
			<li class="info">订单信息</li>
			<li class="username">收货人</li>
			<li class="price">订单金额</li>
			<li class="date">购买日期</li>
			<li class="status">订单状态</li>
			<li class="doit">操作</li>

		</ul>
		
		<div class="lists">
		
		<?php if(!$user_order):?>
        	<div class="alert alert-nobook"><img src="<?php echo base_url('static/images/duola-a-meng_06.png');?>" />您还没有任何订单信息，<a href="<?php echo base_url("lists/index/1") ?>">现在就去购买~</a></div>
        	<?php endif;?>
		<?php foreach ($user_order as $orderVal):?>
			<div class="item" id="order_<?php echo $orderVal->order_id;?>">
				
				<ol>
					
					<dt>订单编号：<?php echo $orderVal->order_number;?></dt>
					<?php $order_book_img = $this->m_order->selectOrderDetailsImg($orderVal->order_id);?>
					<dl class="clearfix">
						<?php foreach ($order_book_img as $orderBookImg):?>
						<a href="<?php echo base_url('lists/item/'.$orderBookImg->book_id);?>" target="_blank">
							<img src="<?php echo base_url('uploads/thumb_50/'.$orderBookImg->book_img);?>" height="50" alt="" />
						</a>
						<?php endforeach;?>
					</dl> 
				
				</ol>
				
				<div class="username"><?php echo $orderVal->order_username;?></div>
				<div class="price"><?php echo $orderVal->order_total_price;?></div>
				<div class="date"><?php echo date("Y-m-d H:i:s",$orderVal->order_create_time);?></div>
				<div class="status">
				<?php 
				if($orderVal->order_status == '10')
				{
					echo '未处理';
				}
				else if($orderVal->order_status == '20')
				{
					echo '打包中';
				}
				else if($orderVal->order_status == '30')
				{
					echo '配送中';
				}
				else if($orderVal->order_status == '40')
				{
					echo '完成';
				}
				else if($orderVal->order_status == '50')
				{
					echo '<b ><a href="Javascript:;" onclick="showErrorMessage(\'<b>原因：</b>'.($orderVal->order_admin_remark?$orderVal->order_admin_remark:"配送小哥，暂未提供备注").'\')" style="color:#F00; text-decoration:underline;">配送失败</a></b>';
				}
				else if($orderVal->order_status == '60')
				{
					echo '被取消';
				}
				else if($orderVal->order_status == '70')
				{
					echo '被取消';
				}
					
				?>
				</div>
				<div class="doit">
					<?php if($orderVal->order_status > 20): ?>
					暂无操作
					<?php endif;?>
					
					<?php if($orderVal->order_status == '10' || $orderVal->order_status == '20'){ ?>
					&nbsp;<a href="Javascript:;" onclick="confirmCan('<?php echo $orderVal->order_id;?>',<?php echo $orderVal->order_number;?>)">取消订单</a>
					<?php }?>

				</div>
			
			
			</div>
		<?php endforeach;?>
		
		
		</div><!-- lists -->
		
	<div class="pagination"><?php echo $this->pagination->pagination(); ?></div>
	
	</div><!-- content -->


</div>

<script>

//取消订单
function confirmCan(id,order_number){
	var myModal = new jBox('Confirm', {

		confirmButton:"我要取消订单",
		cancelButton:"关闭窗口",
		content:"确认取消订单号为："+order_number+"&nbsp;的订单配送？",
		confirm:function(){
			$.ajax({
				url:"<?php echo base_url('ucenter/cancelOrder');?>",
				dataType:"json",
				type:"post",
				data:{"id":id},
				success:function(e){
					if(e.status=='10000'){
						location.reload();
					}else if(e.status=='10007'){
						alertError("订单配送中或已经完成配送，不可取消订单");
					}
				}
			});
		}
	});
	 
	myModal.open();
}

function showErrorMessage(content){
	
	var myModal =new jBox('Modal', {

		title:"配送失败",
		content:content

	});
	 
	myModal.open();
}

</script>
